/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef OHOS_SIM_CONSTANT_H
#define OHOS_SIM_CONSTANT_H

#define ICC_CONTROLLER_REQ_BASE 0x16EFF0
#define ICC_CONTROLLER_REQ_NONE (ICC_CONTROLLER_REQ_BASE + 0)
#define ICC_CONTROLLER_REQ_SEND_RESPONSE (ICC_CONTROLLER_REQ_BASE + 1)

// mnc Length type
#define UNINITIALIZED_MNC -1
#define UNKNOWN_MNC 0
#define DEFAULT_MNC 2

#define MSG_SIM_MWI 0
#define MSG_SIM_CFI 1
#define MSG_SIM_SPN 2

#define MSG_SIM_OBTAIN_ICC_FILE_DONE 100
#define MSG_ICC_REFRESH 31
#define MSG_SIM_APP_READY 1

#define ICC_CALL_FORWARD_TYPE_DISABLED 0
#define ICC_CALL_FORWARD_TYPE_ENABLED 1
#define ICC_CALL_FORWARD_TYPE_UNKNOWN -1

#define SIM_RECORD_MSG_SIM_BASE 0x00
#define MSG_SIM_OBTAIN_IMSI_DONE (3 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_ICCID_DONE (4 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_MBI_DONE (5 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_MBDN_DONE (6 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_MWIS_DONE (7 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_VOICE_MAIL_INDICATOR_CPHS_DONE (8 + SIM_RECORD_MSG_SIM_BASE)

#define MSG_SIM_OBTAIN_AD_DONE (9 + SIM_RECORD_MSG_SIM_BASE) // Admin data
#define MSG_SIM_OBTAIN_MSISDN_DONE (10 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_CPHS_MAILBOX_DONE (11 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_SPN_DONE (12 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_SPDI_DONE (13 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_UPDATE_DONE (14 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_PNN_DONE (15 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_SST_DONE (17 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_ALL_SMS_DONE (18 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_MARK_SMS_READ_DONE (19 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_SET_MBDN_DONE (20 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_SMS_ON_SIM (21 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_SMS_DONE (22 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_CFF_DONE (24 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_SET_CPHS_MAILBOX_DONE (25 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_INFO_CPHS_DONE (26 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_SET_MSISDN_DONE (30 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_CFIS_DONE (32 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_CSP_CPHS_DONE (33 + SIM_RECORD_MSG_SIM_BASE)

#define MSG_SIM_OBTAIN_GID1_DONE (34 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_GID2_DONE (36 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_PLMN_W_ACT_DONE (37 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_OPLMN_W_ACT_DONE (38 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_HPLMN_W_ACT_DONE (39 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_EHPLMN_DONE (40 + SIM_RECORD_MSG_SIM_BASE)
#define MSG_SIM_OBTAIN_FPLMN_DONE (41 + SIM_RECORD_MSG_SIM_BASE)

#define SYSTEM_MSG_SIM_BASE 0x100
#define MSG_SIM_APP_LOCKED (2 + SYSTEM_MSG_SIM_BASE)
#define MSG_SIM_APP_NETWORK_LOCKED (3 + SYSTEM_MSG_SIM_BASE)

// ETSI TS 102 221 V3.3.0 section 13.3 Preferred Languages
#define ELEMENTARY_FILE_PL 0x2F05

// CPHS V4.2 section B.3.1.1, B.4.1 - B.4.7 CPHS information Call forwarding flags and so on
#define ELEMENTARY_FILE_VOICE_MAIL_INDICATOR_CPHS 0x6F11
#define ELEMENTARY_FILE_CFF_CPHS 0x6F13
#define ELEMENTARY_FILE_SPN_CPHS 0x6F14
#define ELEMENTARY_FILE_CSP_CPHS 0x6F15
#define ELEMENTARY_FILE_INFO_CPHS 0x6F16
#define ELEMENTARY_FILE_MAILBOX_CPHS 0x6F17
#define ELEMENTARY_FILE_SPN_SHORT_CPHS 0x6F18

// 3GPP TS 51.011 V4.1.0 section 10 contents of the Elementary Files
#define ELEMENTARY_FILE_ICCID 0x2FE2
#define ELEMENTARY_FILE_IMG 0x4F20
#define ELEMENTARY_FILE_HPLMN 0x6F31
#define ELEMENTARY_FILE_SST 0x6F38
#define ELEMENTARY_FILE_ADN 0x6F3A
#define ELEMENTARY_FILE_FDN 0x6F3B
#define ELEMENTARY_FILE_SMS 0x6F3C
#define ELEMENTARY_FILE_GID1 0x6F3E
#define ELEMENTARY_FILE_GID2 0x6F3F
#define ELEMENTARY_FILE_MSISDN 0x6F40
#define ELEMENTARY_FILE_SPN 0x6F46
#define ELEMENTARY_FILE_SDN 0x6F49
#define ELEMENTARY_FILE_EXT1 0x6F4A
#define ELEMENTARY_FILE_EXT2 0x6F4B
#define ELEMENTARY_FILE_EXT3 0x6F4C
#define ELEMENTARY_FILE_EXT4 0x6F4E
#define ELEMENTARY_FILE_PLMN_W_ACT 0x6F60
#define ELEMENTARY_FILE_OPLMN_W_ACT 0x6F61
#define ELEMENTARY_FILE_HPLMN_W_ACT 0x6F62
#define ELEMENTARY_FILE_FPLMN 0x6F7B
#define ELEMENTARY_FILE_AD 0x6FAD
#define ELEMENTARY_FILE_PNN 0x6FC5
#define ELEMENTARY_FILE_OPL 0x6FC6
#define ELEMENTARY_FILE_MBDN 0x6FC7
#define ELEMENTARY_FILE_EXT6 0x6FC8
#define ELEMENTARY_FILE_MBI 0x6FC9
#define ELEMENTARY_FILE_MWIS 0x6FCA
#define ELEMENTARY_FILE_CFIS 0x6FCB

#define ELEMENTARY_FILE_PBR 0x4F30
#define ELEMENTARY_FILE_IMPI 0x6F02
#define ELEMENTARY_FILE_DOMAIN 0x6F03
#define ELEMENTARY_FILE_IMPU 0x6F04
#define ELEMENTARY_FILE_LI 0x6F05
#define ELEMENTARY_FILE_IST 0x6F07
#define ELEMENTARY_FILE_PCSCF 0x6F09
#define ELEMENTARY_FILE_CST 0x6F32
#define ELEMENTARY_FILE_CSIM_LI 0x6F3A
#define ELEMENTARY_FILE_RUIM_SPN 0x6F41

#define ELEMENTARY_FILE_CSIM_IMSIM 0x6F22
#define ELEMENTARY_FILE_CSIM_CDMAHOME 0x6F28
#define ELEMENTARY_FILE_CSIM_SPN 0x6F41
#define ELEMENTARY_FILE_CSIM_MDN 0x6F44
#define ELEMENTARY_FILE_CSIM_MIPUPP 0x6F4D
#define ELEMENTARY_FILE_CSIM_EPRL 0x6F5A
#define ELEMENTARY_FILE_PSI 0x6FE5
#define ELEMENTARY_FILE_EHPLMN 0x6FD9
#define ELEMENTARY_FILE_LRPLMNSI 0x6FDC

// 3GPP TS 51.011 V4.1.0 section 10.7 files of gsm
#define MASTER_FILE_SIM "3F00"
#define DEDICATED_FILE_TELECOM "7F10"
#define DEDICATED_FILE_GSM "7F20"
#define DEDICATED_FILE_GRAPHICS "5F50"

// ETSI TS 102 221 V3.3.0 section 8.6 resarvation of file IDs
#define DEDICATED_FILE_PHONEBOOK "5F3A"
#define DEDICATED_FILE_ADF "7FFF"

// file controller constant
#define CONTROLLER_REQ_READ_BINARY 0xb0
#define CONTROLLER_REQ_UPDATE_BINARY 0xd6
#define CONTROLLER_REQ_READ_RECORD 0xb2
#define CONTROLLER_REQ_UPDATE_RECORD 0xdc
#define CONTROLLER_REQ_SEEK 0xa2
#define CONTROLLER_REQ_GET_RESPONSE 0xc0

#define ICC_FILE_CURRENT_MODE 4

#define ELEMENTARY_FILE_TYPE_TRANSPARENT 0
#define ELEMENTARY_FILE_TYPE_LINEAR_FIXED 1
#define ELEMENTARY_FILE_TYPE_CYCLIC 3

#define ICC_MASTER_FILE 1
#define ICC_DEDICATED_FILE 2
#define ICC_ELEMENTARY_FILE 4

#define GET_RESPONSE_ELEMENTARY_FILE_SIZE_BYTES 15
#define GET_RESPONSE_ELEMENTARY_FILE_IMG_SIZE_BYTES 10

// controller file type
#define SIZE_ONE_OF_FILE 2
#define SIZE_TWO_OF_FILE 3
#define TYPE_OF_FILE 6
#define STRUCTURE_OF_DATA 13
#define LENTH_OF_RECORD 14

#define MSG_SIM_OBTAIN_SIZE_OF_FIXED_ELEMENTARY_FILE_DONE 1
#define MSG_SIM_OBTAIN_FIXED_ELEMENTARY_FILE_DONE 2
#define MSG_SIM_OBTAIN_SIZE_OF_TRANSPARENT_ELEMENTARY_FILE_DONE 3
#define MSG_SIM_OBTAIN_TRANSPARENT_ELEMENTARY_FILE_DONE 4
#define MSG_SIM_OBTAIN_SIZE_OF_LINEAR_ELEMENTARY_FILE_DONE 5

#define SIM_UNKNOWN_ERROR "unknown"
#define INVALID_VALUE -1

#define MSG_SIM_LOCKED_RECORDS_LOADED 0xf3
#define MSG_SIM_NETWORK_LOCKED_RECORDS_LOADED 0xf4
#define MSG_SIM_SPN_UPDATED 0xf5

#define MSG_ID_DEFAULT 0

const std::string SIM_STATE_ACTION = "com.hos.action.SIM_STATE_CHANGED";
enum {
    ICC_STATE_UNKNOWN = 0,
    ICC_STATE_NOT_READY = 1,
    ICC_STATE_ABSENT = 2,
    ICC_STATE_READY = 3,
    ICC_STATE_LOADED = 4,
    ICC_STATE_IMSI = 5,
};
#endif // OHOS_SIM_CONSTANT_H